<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * Constructs a new mark anchor with default properties.
<span class='line'>  3</span>  *
<span class='line'>  4</span>  * @class Represents an anchor on a given mark. An anchor is itself a mark, but
<span class='line'>  5</span>  * without a visual representation. It serves only to provide useful default
<span class='line'>  6</span>  * properties that can be inherited by other marks. Each type of mark can define
<span class='line'>  7</span>  * any number of named anchors for convenience. If the concrete mark type does
<span class='line'>  8</span>  * not define an anchor implementation specifically, one will be inherited from
<span class='line'>  9</span>  * the mark's parent class.
<span class='line'> 10</span>  *
<span class='line'> 11</span>  * &lt;p>For example, the bar mark provides anchors for its four sides: left,
<span class='line'> 12</span>  * right, top and bottom. Adding a label to the top anchor of a bar,
<span class='line'> 13</span>  *
<span class='line'> 14</span>  * &lt;pre>bar.anchor("top").add(pv.Label);&lt;/pre>
<span class='line'> 15</span>  *
<span class='line'> 16</span>  * will render a text label on the top edge of the bar; the top anchor defines
<span class='line'> 17</span>  * the appropriate position properties (top and left), as well as text-rendering
<span class='line'> 18</span>  * properties for convenience (textAlign and textBaseline).
<span class='line'> 19</span>  *
<span class='line'> 20</span>  * &lt;p>Note that anchors do not &lt;i>inherit&lt;/i> from their targets; the positional
<span class='line'> 21</span>  * properties are copied from the scene graph, which guarantees that the anchors
<span class='line'> 22</span>  * are positioned correctly, even if the positional properties are not defined
<span class='line'> 23</span>  * deterministically. (In addition, it also improves performance by avoiding
<span class='line'> 24</span>  * re-evaluating expensive properties.) If you want the anchor to inherit from
<span class='line'> 25</span>  * the target, use {@link pv.Mark#extend} before adding. For example:
<span class='line'> 26</span>  *
<span class='line'> 27</span>  * &lt;pre>bar.anchor("top").extend(bar).add(pv.Label);&lt;/pre>
<span class='line'> 28</span>  *
<span class='line'> 29</span>  * The anchor defines it's own positional properties, but other properties (such
<span class='line'> 30</span>  * as the title property, say) can be inherited using the above idiom. Also note
<span class='line'> 31</span>  * that you can override positional properties in the anchor for custom
<span class='line'> 32</span>  * behavior.
<span class='line'> 33</span>  *
<span class='line'> 34</span>  * @extends pv.Mark
<span class='line'> 35</span>  * @param {pv.Mark} target the anchor target.
<span class='line'> 36</span>  */</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="NAME">pv.Anchor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">target</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT">  </span><span class="NAME">pv.Mark.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="WHIT">  </span><span class="NAME">this.target</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT">  </span><span class="NAME">this.parent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">target.parent</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 42</span> 
<span class='line'> 43</span> </span><span class="NAME">pv.Anchor.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.extend</span><span class="PUNC">(</span><span class="NAME">pv.Mark</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"name"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> 
<span class='line'> 46</span> </span><span class="COMM">/**
<span class='line'> 47</span>  * The anchor name. The set of supported anchor names is dependent on the
<span class='line'> 48</span>  * concrete mark type; see the mark type for details. For example, bars support
<span class='line'> 49</span>  * left, right, top and bottom anchors.
<span class='line'> 50</span>  *
<span class='line'> 51</span>  * &lt;p>While anchor names are typically constants, the anchor name is a true
<span class='line'> 52</span>  * property, which means you can specify a function to compute the anchor name
<span class='line'> 53</span>  * dynamically. For instance, if you wanted to alternate top and bottom anchors,
<span class='line'> 54</span>  * saying
<span class='line'> 55</span>  *
<span class='line'> 56</span>  * &lt;pre>m.anchor(function() (this.index % 2) ? "top" : "bottom").add(pv.Dot);&lt;/pre>
<span class='line'> 57</span>  *
<span class='line'> 58</span>  * would have the desired effect.
<span class='line'> 59</span>  *
<span class='line'> 60</span>  * @type string
<span class='line'> 61</span>  * @name pv.Anchor.prototype.name
<span class='line'> 62</span>  */</span><span class="WHIT">
<span class='line'> 63</span> 
<span class='line'> 64</span> </span><span class="COMM">/**
<span class='line'> 65</span>  * Returns the anchor target of this mark, if it is derived from an anchor;
<span class='line'> 66</span>  * otherwise returns null. For example, if a label is derived from a bar anchor,
<span class='line'> 67</span>  *
<span class='line'> 68</span>  * &lt;pre>bar.anchor("top").add(pv.Label);&lt;/pre>
<span class='line'> 69</span>  *
<span class='line'> 70</span>  * then property functions on the label can refer to the bar via the
<span class='line'> 71</span>  * &lt;tt>anchorTarget&lt;/tt> method. This method is also useful for mark types
<span class='line'> 72</span>  * defining properties on custom anchors.
<span class='line'> 73</span>  *
<span class='line'> 74</span>  * @returns {pv.Mark} the anchor target of this mark; possibly null.
<span class='line'> 75</span>  */</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="NAME">pv.Anchor.prototype.anchorTarget</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.target</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 79</span> </span></pre></body></html>